const helper = {

  getManageApiPrefix:function () {
    return "/service/manage"
  },
  getClientApiPrefix:function () {
    return "/service/api"
  },

  getClientApiUrl:function(path){
    return this.getClientApiPrefix()+path;
  },

  getManageApiUrl:function(path){
    return this.getManageApiPrefix()+path;
  },

  getFrontApiUrl:function(path){
    return this.getFrontApiUrl()+path;
  },

  getImageApiPrefix:function () {
    return '/upload/backend/news/cover/'
  },

  formatDateTime:function (dates) {
    var ymd = ''
    if (dates == null || dates == '' || dates == '0000-00-00 00:00:00') {
      ymd = ''
    } else {
      var date = new Date(dates)
      var y = date.getFullYear()
      var m = date.getMonth() + 1
      m = m < 10 ? '0' + m : m
      var d = date.getDate()
      d = d < 10 ? ('0' + d) : d
      ymd = y + '-' + m + '-' + d
      let hour = date.getHours()
      hour = hour < 10 ? ('0' + hour) : hour
      let minutes = date.getMinutes()
      minutes = minutes < 10 ? ('0' + minutes) : minutes
      let seconds = date.getSeconds()
      seconds = seconds < 10 ? ('0' + seconds) : seconds
      let time = hour + ':' + minutes + ':' + seconds
      ymd = ymd + ' ' + time
    }
    return ymd
  },
  getCurrentTime:function () {
    return new  Date().getTime();
  },
  formatDate:function (dates) {
    var ymd = ''
    if (dates == null || dates == '' || dates == '0000-00-00') {
      ymd = ''
    } else {
      var date = new Date(dates)
      var y = date.getFullYear()
      var m = date.getMonth() + 1
      m = m < 10 ? '0' + m : m
      var d = date.getDate()
      d = d < 10 ? ('0' + d) : d
      ymd = y + '-' + m + '-' + d
    }
    return ymd
  }

}
export default helper;

